//while循环实现下数字游戏
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
    srand(time(NULL));//使用时间time函数做随机数种子包含在头文件<ctime>中
    int num=rand()%100;
    int guess;
    int count=0;
    while (1)
    {
        cout<<"请输入你的数字:"<<endl;
        cin>>guess;
        if (guess==num){
            cout<<"恭喜你猜对了"<<endl;
            break;
        }
        else if(guess>num){
            cout<<"你才的数字大了"<<endl;
            count++;
        }
        else{
            cout<<"你才的数字小了"<<endl;
            count++;
        }
    }
    cout<<"你一共猜了"<<count<<"次"<<endl;
    return 0;
}